package com.lcy.demo;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by 娄存银 on 2017/4/7.
 */
@Path("user")

public class UserServiceImpl implements UserService{
    @Override
    @GET
    @Path("{id}")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
    @Produces({ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public User getUser(@PathParam("id") Long id) {
        if(id == null){
            return null;
        }
        User user = new User();
        user.setAge((int) (id%100));
        user.setId(id);
        user.setName("name : "+id);
        return user;
    }
}
